<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>AIfES 2: aialgo_sequential_training.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="https://cdn.jsdelivr.net/npm/mathjax@2/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="AIfES_logo_small.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">AIfES 2
   &#160;<span id="projectnumber">2.0.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('aialgo__sequential__training_8h_source.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">aialgo_sequential_training.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="aialgo__sequential__training_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160; </div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;<span class="preprocessor">#ifndef AIALGO_SEQUENTIAL_TRAINING</span></div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;<span class="preprocessor">#define AIALGO_SEQUENTIAL_TRAINING</span></div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160; </div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="aifes__core_8h.html">core/aifes_core.h</a>&quot;</span></div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="aifes__math_8h.html">core/aifes_math.h</a>&quot;</span></div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="aimath__basic_8h.html">basic/base/aimath/aimath_basic.h</a>&quot;</span></div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="aimath__q31_8h.html">basic/base/aimath/aimath_q31.h</a>&quot;</span></div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160; </div>
<div class="line"><a name="l00042"></a><span class="lineno"><a class="line" href="aialgo__sequential__training_8h.html#aaa72bf9da57a600c0d4fef4ba03f725e">   42</a></span>&#160;uint32_t <a class="code" href="aialgo__sequential__training_8h.html#aaa72bf9da57a600c0d4fef4ba03f725e">aialgo_sizeof_training_memory</a>(<a class="code" href="structaimodel.html">aimodel_t</a> *model, <a class="code" href="structaiopti.html">aiopti_t</a> *optimizer);</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160; </div>
<div class="line"><a name="l00056"></a><span class="lineno"><a class="line" href="aialgo__sequential__training_8h.html#aa6ae098c2add3651d216724f102e931b">   56</a></span>&#160;uint8_t <a class="code" href="aialgo__sequential__training_8h.html#aa6ae098c2add3651d216724f102e931b">aialgo_schedule_training_memory</a>(<a class="code" href="structaimodel.html">aimodel_t</a> *model, <a class="code" href="structaiopti.html">aiopti_t</a> *optimizer, <span class="keywordtype">void</span> *memory_ptr, uint32_t memory_size);</div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160; </div>
<div class="line"><a name="l00063"></a><span class="lineno"><a class="line" href="aialgo__sequential__training_8h.html#a62a55277765b0bdd5c88955eb92e4c13">   63</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="aialgo__sequential__training_8h.html#a62a55277765b0bdd5c88955eb92e4c13">aialgo_init_model_for_training</a>(<a class="code" href="structaimodel.html">aimodel_t</a> *model, <a class="code" href="structaiopti.html">aiopti_t</a> *optimizer);</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160; </div>
<div class="line"><a name="l00070"></a><span class="lineno"><a class="line" href="aialgo__sequential__training_8h.html#aca4ec290b2db30cc76ad78aff649a69d">   70</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="aialgo__sequential__training_8h.html#aca4ec290b2db30cc76ad78aff649a69d">aialgo_backward_model</a>(<a class="code" href="structaimodel.html">aimodel_t</a> *model, <a class="code" href="structaitensor.html">aitensor_t</a> *target_data);</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160; </div>
<div class="line"><a name="l00105"></a><span class="lineno"><a class="line" href="aialgo__sequential__training_8h.html#a6557fccf302f653bcdcb77830463d14d">  105</a></span>&#160;uint8_t <a class="code" href="aialgo__sequential__training_8h.html#a6557fccf302f653bcdcb77830463d14d">aialgo_train_model</a>(<a class="code" href="structaimodel.html">aimodel_t</a> *model, <a class="code" href="structaitensor.html">aitensor_t</a> *input_tensor, <a class="code" href="structaitensor.html">aitensor_t</a> *target_tensor, <a class="code" href="structaiopti.html">aiopti_t</a> *optimizer, uint32_t batch_size);</div>
<div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160; </div>
<div class="line"><a name="l00114"></a><span class="lineno"><a class="line" href="aialgo__sequential__training_8h.html#ab06a58b69f3136374e2dc6664f56e0c7">  114</a></span>&#160;uint8_t <a class="code" href="aialgo__sequential__training_8h.html#ab06a58b69f3136374e2dc6664f56e0c7">aialgo_calc_loss_model_f32</a>(<a class="code" href="structaimodel.html">aimodel_t</a> *model, <a class="code" href="structaitensor.html">aitensor_t</a> *input_data, <a class="code" href="structaitensor.html">aitensor_t</a> *target_data, <span class="keywordtype">float</span> *result);</div>
<div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160; </div>
<div class="line"><a name="l00123"></a><span class="lineno"><a class="line" href="aialgo__sequential__training_8h.html#a9d2a18685d1db30e00c91c194bea8104">  123</a></span>&#160;uint8_t <a class="code" href="aialgo__sequential__training_8h.html#a9d2a18685d1db30e00c91c194bea8104">aialgo_calc_loss_model_q31</a>(<a class="code" href="structaimodel.html">aimodel_t</a> *model, <a class="code" href="structaitensor.html">aitensor_t</a> *input_data, <a class="code" href="structaitensor.html">aitensor_t</a> *target_data, <a class="code" href="structaiscalar__q31.html">aiscalar_q31_t</a> *result);</div>
<div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160; </div>
<div class="line"><a name="l00130"></a><span class="lineno"><a class="line" href="aialgo__sequential__training_8h.html#a20ba9e0bdcfd4e36bc1168789de7e99f">  130</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="aialgo__sequential__training_8h.html#a20ba9e0bdcfd4e36bc1168789de7e99f">aialgo_zero_gradients_model</a>(<a class="code" href="structaimodel.html">aimodel_t</a> *model, <a class="code" href="structaiopti.html">aiopti_t</a> *optimizer);</div>
<div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160; </div>
<div class="line"><a name="l00137"></a><span class="lineno"><a class="line" href="aialgo__sequential__training_8h.html#a4650ca244c2d5086eb80190d2416f86e">  137</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="aialgo__sequential__training_8h.html#a4650ca244c2d5086eb80190d2416f86e">aialgo_update_params_model</a>(<a class="code" href="structaimodel.html">aimodel_t</a> *model, <a class="code" href="structaiopti.html">aiopti_t</a> *optimizer);</div>
<div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160; </div>
<div class="line"><a name="l00145"></a><span class="lineno"><a class="line" href="aialgo__sequential__training_8h.html#ab19a3d00e7ac130806780cc90e317a09">  145</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="aialgo__sequential__training_8h.html#ab19a3d00e7ac130806780cc90e317a09">aialgo_print_loss_specs</a>(<a class="code" href="structailoss.html">ailoss_t</a> *loss);</div>
<div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160; </div>
<div class="line"><a name="l00153"></a><span class="lineno"><a class="line" href="aialgo__sequential__training_8h.html#aa0a7ab4189d2f68c675d42aa687758e6">  153</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="aialgo__sequential__training_8h.html#aa0a7ab4189d2f68c675d42aa687758e6">aialgo_print_optimizer_specs</a>(<a class="code" href="structaiopti.html">aiopti_t</a> *opti);</div>
<div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160; </div>
<div class="line"><a name="l00162"></a><span class="lineno"><a class="line" href="aialgo__sequential__training_8h.html#ab6ea378b18812cf68fb4ae70c57380a5">  162</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="aialgo__sequential__training_8h.html#ab6ea378b18812cf68fb4ae70c57380a5">aialgo_initialize_parameters_model</a>(<a class="code" href="structaimodel.html">aimodel_t</a> *model);</div>
<div class="line"><a name="l00163"></a><span class="lineno">  163</span>&#160; </div>
<div class="line"><a name="l00164"></a><span class="lineno">  164</span>&#160;<span class="preprocessor">#endif </span><span class="comment">// AIALGO_SEQUENTIAL_TRAINING</span></div>
<div class="ttc" id="aaialgo__sequential__training_8h_html_a20ba9e0bdcfd4e36bc1168789de7e99f"><div class="ttname"><a href="aialgo__sequential__training_8h.html#a20ba9e0bdcfd4e36bc1168789de7e99f">aialgo_zero_gradients_model</a></div><div class="ttdeci">void aialgo_zero_gradients_model(aimodel_t *model, aiopti_t *optimizer)</div><div class="ttdoc">Set the gradients to zero.</div></div>
<div class="ttc" id="aaialgo__sequential__training_8h_html_a4650ca244c2d5086eb80190d2416f86e"><div class="ttname"><a href="aialgo__sequential__training_8h.html#a4650ca244c2d5086eb80190d2416f86e">aialgo_update_params_model</a></div><div class="ttdeci">void aialgo_update_params_model(aimodel_t *model, aiopti_t *optimizer)</div><div class="ttdoc">Perform the optimization step on the model parameters.</div></div>
<div class="ttc" id="aaialgo__sequential__training_8h_html_a62a55277765b0bdd5c88955eb92e4c13"><div class="ttname"><a href="aialgo__sequential__training_8h.html#a62a55277765b0bdd5c88955eb92e4c13">aialgo_init_model_for_training</a></div><div class="ttdeci">void aialgo_init_model_for_training(aimodel_t *model, aiopti_t *optimizer)</div><div class="ttdoc">Initialize the optimization memory of the model layers.</div></div>
<div class="ttc" id="aaialgo__sequential__training_8h_html_a6557fccf302f653bcdcb77830463d14d"><div class="ttname"><a href="aialgo__sequential__training_8h.html#a6557fccf302f653bcdcb77830463d14d">aialgo_train_model</a></div><div class="ttdeci">uint8_t aialgo_train_model(aimodel_t *model, aitensor_t *input_tensor, aitensor_t *target_tensor, aiopti_t *optimizer, uint32_t batch_size)</div><div class="ttdoc">Perform one training epoch on all data batches of the dataset using backpropagation.</div></div>
<div class="ttc" id="aaialgo__sequential__training_8h_html_a9d2a18685d1db30e00c91c194bea8104"><div class="ttname"><a href="aialgo__sequential__training_8h.html#a9d2a18685d1db30e00c91c194bea8104">aialgo_calc_loss_model_q31</a></div><div class="ttdeci">uint8_t aialgo_calc_loss_model_q31(aimodel_t *model, aitensor_t *input_data, aitensor_t *target_data, aiscalar_q31_t *result)</div><div class="ttdoc">Calculate the loss in Q31  data type.</div></div>
<div class="ttc" id="aaialgo__sequential__training_8h_html_aa0a7ab4189d2f68c675d42aa687758e6"><div class="ttname"><a href="aialgo__sequential__training_8h.html#aa0a7ab4189d2f68c675d42aa687758e6">aialgo_print_optimizer_specs</a></div><div class="ttdeci">void aialgo_print_optimizer_specs(aiopti_t *opti)</div><div class="ttdoc">Print the optimizer specs.</div></div>
<div class="ttc" id="aaialgo__sequential__training_8h_html_aa6ae098c2add3651d216724f102e931b"><div class="ttname"><a href="aialgo__sequential__training_8h.html#aa6ae098c2add3651d216724f102e931b">aialgo_schedule_training_memory</a></div><div class="ttdeci">uint8_t aialgo_schedule_training_memory(aimodel_t *model, aiopti_t *optimizer, void *memory_ptr, uint32_t memory_size)</div><div class="ttdoc">Assign the memory for model training.</div></div>
<div class="ttc" id="aaialgo__sequential__training_8h_html_aaa72bf9da57a600c0d4fef4ba03f725e"><div class="ttname"><a href="aialgo__sequential__training_8h.html#aaa72bf9da57a600c0d4fef4ba03f725e">aialgo_sizeof_training_memory</a></div><div class="ttdeci">uint32_t aialgo_sizeof_training_memory(aimodel_t *model, aiopti_t *optimizer)</div><div class="ttdoc">Calculate the memory requirements for model training.</div></div>
<div class="ttc" id="aaialgo__sequential__training_8h_html_ab06a58b69f3136374e2dc6664f56e0c7"><div class="ttname"><a href="aialgo__sequential__training_8h.html#ab06a58b69f3136374e2dc6664f56e0c7">aialgo_calc_loss_model_f32</a></div><div class="ttdeci">uint8_t aialgo_calc_loss_model_f32(aimodel_t *model, aitensor_t *input_data, aitensor_t *target_data, float *result)</div><div class="ttdoc">Calculate the loss in F32  data type.</div></div>
<div class="ttc" id="aaialgo__sequential__training_8h_html_ab19a3d00e7ac130806780cc90e317a09"><div class="ttname"><a href="aialgo__sequential__training_8h.html#ab19a3d00e7ac130806780cc90e317a09">aialgo_print_loss_specs</a></div><div class="ttdeci">void aialgo_print_loss_specs(ailoss_t *loss)</div><div class="ttdoc">Print the loss specs.</div></div>
<div class="ttc" id="aaialgo__sequential__training_8h_html_ab6ea378b18812cf68fb4ae70c57380a5"><div class="ttname"><a href="aialgo__sequential__training_8h.html#ab6ea378b18812cf68fb4ae70c57380a5">aialgo_initialize_parameters_model</a></div><div class="ttdeci">void aialgo_initialize_parameters_model(aimodel_t *model)</div><div class="ttdoc">Initialize the parameters of the given model with their default initialization method.</div></div>
<div class="ttc" id="aaialgo__sequential__training_8h_html_aca4ec290b2db30cc76ad78aff649a69d"><div class="ttname"><a href="aialgo__sequential__training_8h.html#aca4ec290b2db30cc76ad78aff649a69d">aialgo_backward_model</a></div><div class="ttdeci">void aialgo_backward_model(aimodel_t *model, aitensor_t *target_data)</div><div class="ttdoc">Perform the backward pass.</div></div>
<div class="ttc" id="aaifes__core_8h_html"><div class="ttname"><a href="aifes__core_8h.html">aifes_core.h</a></div><div class="ttdoc">AIfES 2 core interface.</div></div>
<div class="ttc" id="aaifes__math_8h_html"><div class="ttname"><a href="aifes__math_8h.html">aifes_math.h</a></div><div class="ttdoc">AIfES 2 math interface.</div></div>
<div class="ttc" id="aaimath__basic_8h_html"><div class="ttname"><a href="aimath__basic_8h.html">aimath_basic.h</a></div><div class="ttdoc">Basic data-type independent math operations.</div></div>
<div class="ttc" id="aaimath__q31_8h_html"><div class="ttname"><a href="aimath__q31_8h.html">aimath_q31.h</a></div><div class="ttdoc">Definition of the Q31 (aiq31) data-type.</div></div>
<div class="ttc" id="astructailoss_html"><div class="ttname"><a href="structailoss.html">ailoss</a></div><div class="ttdoc">AIfES loss interface.</div><div class="ttdef"><b>Definition:</b> aifes_core.h:385</div></div>
<div class="ttc" id="astructaimodel_html"><div class="ttname"><a href="structaimodel.html">aimodel</a></div><div class="ttdoc">AIfES artificial neural network model.</div><div class="ttdef"><b>Definition:</b> aifes_core.h:181</div></div>
<div class="ttc" id="astructaiopti_html"><div class="ttname"><a href="structaiopti.html">aiopti</a></div><div class="ttdoc">AIfES optimizer interface.</div><div class="ttdef"><b>Definition:</b> aifes_core.h:438</div></div>
<div class="ttc" id="astructaiscalar__q31_html"><div class="ttname"><a href="structaiscalar__q31.html">aiscalar_q31</a></div><div class="ttdoc">Single quantized Q31  value/scalar.</div><div class="ttdef"><b>Definition:</b> aimath_q31.h:156</div></div>
<div class="ttc" id="astructaitensor_html"><div class="ttname"><a href="structaitensor.html">aitensor</a></div><div class="ttdoc">A tensor in AIfES.</div><div class="ttdef"><b>Definition:</b> aifes_math.h:89</div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_1e5d3661ed79af157d57e64a38265d09.html">basic</a></li><li class="navelem"><a class="el" href="dir_90008ee2b0f86999412b56217da88d54.html">base</a></li><li class="navelem"><a class="el" href="dir_bd8ee926357880309e83f96383a42e12.html">aialgo</a></li><li class="navelem"><a class="el" href="aialgo__sequential__training_8h.html">aialgo_sequential_training.h</a></li>
    <li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1 </li>
  </ul>
</div>
</body>
</html>
